package com.lanou.zy.projecta.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.lanou.zy.projecta.fragment.MainTitleFragment;
import com.lanou.zy.projecta.greedao.entity.SlideResult;

import java.util.List;

/**
 * Created by dllo on 15/10/30.
 */
public class RecommendViewPagerAdapter extends FragmentPagerAdapter{
    private List<SlideResult> slide;

    public RecommendViewPagerAdapter(FragmentManager fm) {
        super(fm);
    }


    public void addData(List<SlideResult> datas) {
        slide = datas;
        notifyDataSetChanged();
    }

    @Override
    public Fragment getItem(int position) {
        SlideResult s = slide.get(position % slide.size());
        String url = s.getPhoto();

        return MainTitleFragment.getInstance(url);
    }

    @Override
    public int getCount() {
      return slide != null && slide.size() > 0 ? Integer.MAX_VALUE : 0;
    }

}

